const fs = require("fs");
const { baseUrl } = require("./utils");
const path = require("path");

const propsPath = path.join(baseUrl, "../templates");
const output = [];
fs.readdirSync(propsPath).forEach((name) => {
	if (/\.js/.test(name)) return;
	if (!fs.existsSync(path.join(propsPath, name, "prompt.js"))) return
	output.push({
		name,
		fn: require(`./${name}/prompt.js`)
	})
});

module.exports = function (plop) {
	output.forEach((item) => {
		plop.setGenerator(item.name, item.fn(plop))
	})
}